<!--
 * @Description: 顶部导航栏
 * @Author: liushuang
 * @Date: 2022-12-02 17:44:24
 * @LastEditTime: 2022-12-05 17:24:53
-->

<template>
  <div class="header">
    <div class="header-left">
      <RowMenu position="left" />
    </div>
    <div class="header-center">
      <div class="center-logo">
        <span>昆仑后台管理系统</span>
      </div>
    </div>
    <!-- 头部一级导航 -->
    <div class="header-right">
      <RowMenu position="right" />
      <div class="header-user-con">
        <!-- 用户名下拉菜单 -->
        <el-dropdown class="user-name" trigger="hover" @command="handleCommand">
          <div class="dropdown-link">
            <i class="mdi mdi-account"></i>
            <span class="userName">{{ userinfo.name }} </span>
            <i class="mdi mdi-chevron-down"></i>
          </div>
          <template #dropdown>
            <el-dropdown-menu class="drop-container">
              <el-dropdown-item command="loginout">
                <div class="drop-item">
                  <i class="mdi mdi-logout"></i>
                  <span>退出登录</span>
                </div>
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>
<script setup>
import { computed } from 'vue'
import { useStore } from 'vuex'
import RowMenu from './components/RowMenu.vue'

const store = useStore()

const userinfo = computed(() => store.state.user.userInfo)
// 用户名下拉菜单选择事件
const handleCommand = (command) => {
  if (command === 'loginout') {
    store.dispatch('user/logout')
  }
}

</script>
<style scoped lang="scss">
@import '@/styles/color.scss';
.header {
  background-color: #445471;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 72px;
  font-size: 22px;
  color: #333;
  user-select: none;
  box-shadow: 1px 0 5px 1px rgba(0, 0, 0, 0.5);
  .header-left {
    position: absolute;
    height: 100%;
    width: 550px;
    left: 0;
    display: flex;
    z-index: 2;
  }
  .header-right {
    position: absolute;
    height: 100%;
    width: 550px;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    box-sizing: border-box;
    padding-right: 14px;
    z-index: 2;
  }
  .header-center {
    position: absolute;
    height: 100%;
    left: 0;
    right: 0;
    background-image: url('@/assets/image/header_bk_1.png');
    background-size: 100% 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    .center-logo {
      height: 65px;
      width: 100%;
      margin: 0 26%;
      display: flex;
      align-items: center;
      justify-content: center;
      background-image: url('@/assets/image/header_bk_2.png');
      background-size: 100% 100%;
      color: #fff;
      font-size: 32px;
      text-shadow: 0px 0px 9px #6696d8;
      line-height: 35px;
      // font-weight: 600;
      .logo {
        overflow: hidden;
        width: 43px;
        height: 43px;
        background: #fff;
        border-radius: 50%;
        box-sizing: border-box;
        padding: 2px;
        margin-right: 22px;
        flex-shrink: 0;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
.header .logo {
  float: left;
  width: 250px;
  color: #4e5969;
  font-weight: 600;
  font-size: 24px;
  margin-left: 24px;
}
.header-user-con {
  display: flex;
  height: 70px;
  align-items: center;
}
.btn-fullscreen {
  transform: rotate(45deg);
  margin-right: 5px;
  font-size: 24px;
}
.btn-bell,
.btn-fullscreen {
  position: relative;
  width: 30px;
  height: 30px;
  text-align: center;
  border-radius: 15px;
  cursor: pointer;
}
.btn-bell-badge {
  position: absolute;
  right: 0;
  top: -2px;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: #f56c6c;
  color: #333;
}
.btn-bell .el-icon-bell {
  color: #333;
}
.user-name {
  margin-left: 10px;
  font-size: 20px;
}
.user-avator {
  margin-left: 20px;
}
.user-avator img {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.dropdown-link {
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: $font-color;
  border-radius: 4px;
  .userName {
    font-size: 12px;
    margin-left: 10px;
    margin-right: 12px;
  }
}

.drop-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 180px;
  font-size: 12px;
  padding: 10px;
  box-sizing: border-box;

  .drop-item {
    font-size: 12px !important;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
    // color: #4a5974;
    font-weight: 600;
    & > span {
      margin-left: 10px;
    }
  }
}

:deep(.el-dropdown-menu__item) {
  text-align: center;
  width: 100%;
  border-radius: 4px;
  box-sizing: border-box;
}
</style>
